<!--#include file="Credenciales.asp" -->
<script language="vbscript" runat="server">
'***********************************************
' SQL Server Conexion script- © Cybergoda code library (www.cybergoda.com)
' Visit http://www.cybergoda.com for hundreds of ASP scripts
' This notice must stay intact for legal use
'***********************************************/
'***********************************************/
'***********************************************/
'***********************************************/
  
' -------------------------------------------------------------------------------------------------------
Function RecordBD(qSQL, qCampo, qBase)
On Error Resume Next
	dim qPathFile, cn, rs, wBD, wPsw, wSrv
	wBD = WhichBD(qBase)
	wUsr = UserdBD()
	wPsw = PasswordBD()
	wSrv = ServerName()
	qPathFile = Server.MapPath(wBD)
	set cn = Server.CreateObject("ADODB.Connection")	
	cn.Open "Driver={SQL Server};Server=" & wSrv & ";Database=" & wBD & ";Uid=" & wUsr & ";Pwd=" & wPsw & ";"  
	set rs=cn.execute(qSQL)
	If rs.eof then
		RecordBD = "none"
	Else
		rs.movefirst
		RecordBD = rs(qCampo)
	End If
	rs.close
	set rs = nothing
	cn.close
	set cn = Nothing
End Function
' -------------------------------------------------------------------------------------------------------
Function MatrixBD(qSQL, qBase)
On Error Resume Next
	dim qPathFile, cn, rs, wBD, wUsr, wPsw, wSrv
	wBD = WhichBD(qBase)
	wUsr = UserdBD()
	wPsw = PasswordBD()
	wSrv = ServerName()
	qPathFile = Server.MapPath(wBD)
	set cn = Server.CreateObject("ADODB.Connection")
	cn.Open "Driver={SQL Server};Server=" & wSrv & ";Database=" & wBD & ";Uid=" & wUsr & ";Pwd=" & wPsw & ";"  
	set rs = cn.execute(qSQL)
	If rs.eof then
		MatrixBD = "none"
	Else
		MatrixBD = rs.getrows				
	End If
	rs.close
	set rs = nothing
	cn.close
	set cn = Nothing
End Function
' -------------------------------------------------------------------------------------------------------
Function ExecuteBD(qSQL, qBase)
On Error Resume Next
	dim qPathFile, cn, wBD
	wBD = WhichBD(qBase)
	wUsr = UserdBD()
	wPsw = PasswordBD()
	wSrv = ServerName()
	qPathFile = Server.MapPath(wBD)
	set cn = Server.CreateObject("ADODB.Connection")
	cn.Open "Driver={SQL Server};Server=" & wSrv & ";Database=" & wBD & ";Uid=" & wUsr & ";Pwd=" & wPsw & ";"
	ExecuteBD = "El proceso no concluyo satisfactoriamente"
	cn.execute(qSQL)
  
	If cn.Errors.Count = 0 Then
		ExecuteBD = "Proceso concluido"
	Else  
    For Each Err In cn.Errors
      ExecuteBD = ExecuteBD & "-" & Err.Description
  Next
  cn.Errors.Clear
  End If
  cn.close
  set cn = Nothing
  End Function
  ' -------------------------------------------------------------------------------------------------------
  Function IfExistBD(qSQL, qBase)
  On Error Resume Next
  dim qPathFile, cn, rs, wBD
  wBD = WhichBD(qBase)
  wUsr = UserdBD()
  wPsw = PasswordBD()
  wSrv = ServerName()
  qPathFile = Server.MapPath(wBD)
  set cn = Server.CreateObject("ADODB.Connection")
  cn.Open "Driver={SQL Server};Server=" & wSrv & ";Database=" & wBD & ";Uid=" & wUsr & ";Pwd=" & wPsw & ";"  
	set rs=cn.execute(qSQL)
	If rs.eof then
		IfExistBD = False
	Else
		IfExistBD = True
	End If
	rs.close
	set rs = nothing
	cn.close
	set cn = Nothing
End Function
</script>